﻿$(document).ready(function (event) 
{
    // Set initial picture
    var postcode = $('#Address_PostCode').val();
    $("#imgMap").attr("src", "http://maps.googleapis.com/maps/api/staticmap?center=" + postcode + "&zoom=14&size=300x300&maptype=roadmap&sensor=false&markers=color:green%7Clabel:P%7C" + postcode);
   

    var fileList = $('#FileList').val();

    fileList = fileList.split(',');

    $(fileList).each(function (index) {

        if (fileList[index].length > 1) {
            var img = $('<img src="/uploadtodelete/' + fileList[index] + '" class="imgupload" />');
            var rmBtn = $('<input type="button" value="Remove" tag ="' + index + '" class="ui-state-hover" />').click(function () {
                $('#divFile' + $(this).attr('tag')).remove();
                $('#FileList').val($('#FileList').val().replace(',' + fileList[index], ''));
            });
            var div = $('<div id="divFile' + index++ + '" />').addClass('imguploadedbox').append(img);
            $(div).append(rmBtn);

            $('#fileResult').append($(div));

        }
    });

    /* Price Listing */
    var PriceJson = Array();
    var tempPrice = $.parseJSON($('#PriceListFinal').val());
	
    if (tempPrice != null) {
        PriceJson = tempPrice;
    }

    var tempHtml = '';
    $(tempPrice).each(function (index) {
        tempHtml += '<div style="float:left; width:200px;">' + tempPrice[index].Vehicle + '      £ ' + tempPrice[index].Price + ' / ' + tempPrice[index].PriceDuration + ' </div><br/>';
    });

    $('#PriceList').html(tempHtml);
});    